package org.example.product.controller;

import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.example.product.bean.Product;
import org.example.product.service.ProductService;
import org.springframework.web.bind.annotation.*;

/**
 * @Author : wer
 * @Date: 2025/6/21 12:52
 * @Description: 商品服务api
 */

@RestController
@RequestMapping("/product")
public class ProductController {

    @Resource
    ProductService productService;

    @GetMapping("/{id}")
    public Product getProduct(@PathVariable("id") Long productId,
                              HttpServletRequest request) {
        String token = request.getHeader("x-token");
        System.out.println("拿到x-token：" + token);
        return productService.getProductById(productId);
    }
}
